﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Web;
using System.ServiceModel;
using System.IO;

namespace FrontEnd_step2
{
    class ModdbFrontEnd
    {
        Moddb08_WCF.Itest client;
        
        public ModdbFrontEnd()
        {
            WebChannelFactory<Moddb08_WCF.Itest> factory = new WebChannelFactory<Moddb08_WCF.Itest>(new Uri("http://localhost:9998"));
            client = factory.CreateChannel();
           
        }

        public Moddb08_WCF.Tables GetAllTables()
        {
            Moddb08_WCF.Tables tables = client.GetAllTables();
            return tables;
        }

        public Moddb08_WCF.Columns GetAllColumns(string tableName)
        {
            return client.GetAllColumnsOfTable(tableName);
        }

        public Moddb08_WCF.Rows GetAllRows(string tableName)
        {
            return client.GetAllRows(tableName);
        }

        public bool CreateTable(string tableName)
        {
            client.AddNewTable(new Moddb08_WCF.Table(tableName));
            return true;

        }

        public Stream GetColumnData(string tableName, string rowID, string columnName)
        {
            return client.GetColumnData(tableName, rowID, columnName);
        }

        
    }
}
